﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:conv="clr-namespace:QQ_LoL_Localizer.Converters"
                    xmlns:cmd="clr-namespace:QQ_LoL_Localizer.Commands">
    <conv:VisibilityConverter x:Key="VisibilityConverter" />
    <conv:FixStatusTextConverter x:Key="TextStatusConverter"/>
    <conv:ColorConverter x:Key="ColorConverter"/>
    <conv:BehaviorConverter x:Key="BehaviorConverter"/>
    
    <cmd:OpenFileCommand x:Key="OpenFileCommand"/>
    <cmd:RunGameCommand x:Key="RunGameCommand"/>
    <cmd:FixAllCommand x:Key="FixAllCommand"/>
    <cmd:FixSelectedCommand x:Key="FixSelectedCommand"/>
    <cmd:RestoreAllCommand x:Key="RestoreAllCommand"/>
    <cmd:RestoreSelectedCommand x:Key="RestoreSelectedCommand"/>
    <cmd:RefreshCommand x:Key="RefreshCommand"/>
    
    <ContextMenu x:Key="ViewItemContextMenu">
        <MenuItem Header="Fix file" Command="{StaticResource FixSelectedCommand}"
                  CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListView}}"/>
        <MenuItem Header="Restore file" Command="{Binding RestoreSelectedCommand}"
                  CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListView}}"/>
        <MenuItem Header="Open location" Command="{StaticResource OpenFileCommand}"
                  CommandParameter="{Binding Path=SelectedItem, RelativeSource={RelativeSource FindAncestor, AncestorType=ListView}}"/>
    </ContextMenu>

    <Style TargetType="Label" x:Key="BaseViewLabel">
        <Setter Property="FontFamily" Value="Segoe UI SemiBold"/>
        <Setter Property="FontSize" Value="26"/>
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>

    <Style TargetType="Label" x:Key="PlayLabel">
        <Setter Property="FontSize" Value="26" />
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="FontFamily" Value="Segoe UI Semibold"/>
    </Style>

    <!-- Set default button style -->
    <Style TargetType="Button">
        <Setter Property="Margin" Value="4"/>
    </Style>
    
    <!-- Set default list view item style to be streched -->
    <Style TargetType="ListViewItem">
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="ContextMenu" Value="{StaticResource ViewItemContextMenu}" />
    </Style>
    
    <!-- Default Separator style -->
    <Style TargetType="Separator">
        <Setter Property="Margin" Value="0,10"/>
    </Style>
    
    <DataTemplate x:Key="FileItemTemplate" DataType="ListViewItem">
        <Grid HorizontalAlignment="Stretch" Height="25">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="20"/>
            </Grid.ColumnDefinitions>
            <Rectangle Grid.ColumnSpan="2" Fill="{Binding IsFixed, Converter={StaticResource ColorConverter}}" Opacity="0.6" StrokeThickness="0"/>
            <CheckBox IsChecked="{Binding IsFixed}"
                      HorizontalAlignment="Right" VerticalAlignment="Center"
                      IsTabStop="False" IsManipulationEnabled="False" IsEnabled="False"
                      Grid.Column="1"/>
            <Label Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{Binding FilePath}"/>
        </Grid>
    </DataTemplate>
    
    <ControlTemplate x:Key="PlayButtonTemplate" TargetType="Button">
        <Grid>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="commonStates">
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="overlay" Storyboard.TargetProperty="Opacity" RepeatBehavior="Forever" >
                                <LinearDoubleKeyFrame KeyTime="0:0:0.0" Value="0" />
                                <LinearDoubleKeyFrame KeyTime="0:0:0.5" Value="0.2" />
                                <LinearDoubleKeyFrame KeyTime="0:0:1.0" Value="0" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Normal" />
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <Label Content="PLAY" Style="{StaticResource PlayLabel}" />
                <Grid>
                    <Image Source="lol_button.png" />
                    <Ellipse x:Name="overlay" Fill="{TemplateBinding Background}" Opacity="0"  Margin="4" />
                </Grid>
                <Label Content="NOW" Style="{StaticResource PlayLabel}" />
            </StackPanel>
        </Grid>
    </ControlTemplate>
    

</ResourceDictionary>